/**********************************************************************
 * created by lei.he on 2020/07/28 for router main file
 **********************************************************************/
// 引入助手包
const {HandleLogs} = require('../utils')

// 引入用户描述的数据模型 userScheme
const userScheme = require('../schema/userSchema')

exports.Router = (app) => {
    app.post('/user/login',(req,res) =>{
        HandleLogs('post uese/login',req.body)
        let data = req.body
        userScheme.findOne({userID:data.userID,userPwd:data.userPwd},(err,doc) => {
            if (!!err) {
                HandleLogs('post uese/login 服务器错误',err)
                res.send({code:500,message : '登录失败，服务器错误'})
            } else {
                HandleLogs('post user/login 登录成功',doc)
                if (!!doc) {
                    res.send({code:200,message:'',data:doc})
                } else {
                    res.send({code:400,message:'用户名或密码错误'})
                }
            }
        })
    })
}